import requests,json

#获取地理编码
def geocode(key, address, city=None, batch="false", sig=None, output="json", callback=None):
    """地址转换"""
    geocode_url = "https://restapi.amap.com/v3/geocode/geo?parameters"
    params = {
        "key": key,
        "address": address,
        "city": city,
        "batch": batch,
        "sig": sig,
        "output": output,
        "callback": callback
    }
    r = requests.get(geocode_url, params=params)
    return r.json()

#步行
def foot(key, origin, destination, sig=None, output="json", callback=None):
    """规划行走路线"""
    foot_url = "https://restapi.amap.com/v3/direction/walking?parameters"
    params = {
        "key": key,
        "origin": origin,
        "destination": destination,
        "sig": sig,
        "output": output,
        "callback": callback
    }
    r = requests.get(foot_url, params=params)
    return r.json()